home *** CD-ROM | disk | FTP | other *** search
-
- ;IconApp
-
- Include MacTraps.D
- Include SysEqu.D
- Include PackMacs.Txt
-
- ;------------------------------Macros-----------------
- ; IconDraw assumes that D5 contains the total number
- ; of resources of type 'ICN#' in the application, and
- ; D6 is an index to the icon we are going to plot next.
- ; A0-> the sourcerect,A1-> the destrect and
- ; D0-> the number of bytes to transfer.
-
- MACRO IconDraw IRect =
- clr.l -(SP) ;handle
- move.L #'ICN#',-(SP) ;res type
- move D6,-(SP) ;index
- _GetIndResource
- move.l (SP),A0
- movea.l (A0),A0 ;handle to ptr
- cmpa.l #0,A0 ;nil?
- beq CloseRez ;yes, so exit
- lea iconmap,A1
- movea.l (A1),A1
- move.l #128,D0
- _BlockMove ;copy icon res to iconmap
- pea {IRect}
- lea iconmap,A1 ;get icon handle
- move.l A1,-(SP)
- _PlotIcon ;plot icon in rect
- |
-
- MACRO CheckDItem Item =
- move.l (A2),-(SP) ; get Dialog pointer
- move.w {Item},-(SP) ; Dialog item in question
- pea theType(A5) ; VAR type
- pea theItem(A5) ; VAR item
- pea theRect(A5) ; VAR box
- _GetDItem
- |
- XDEF START ; linker requisite
- ;-------------------Equates----------------------
- AllEvents equ $0000FFFF
- DWindLen equ $AA
- ;-------------------Initialize Managers-----------
- START
- pea -4(A5) ; push Quickdraw globals
- _InitGraf ; init Quickdraw
- _InitFonts ; init Font manager
- _InitWindows ; init Window manager
- _InitMenus ; init Menu manager
- clr.l -(SP) ; no restart procedure
- _InitDialogs ; init Dialog manager
- _TEInit ; init TextEdit
- move.l #AllEvents,D0 ; all standard events
- _FlushEvents ; flushed from event queue
- _InitCursor ; get standard arrow cursor
- ;--------------------------Miscellaneous------------------
- move.l #128,D0 ; 128 bytes for icon
- _NewPtr ; get pointer
- cmpi #0,D0 ; error?
- Bne Quit ; yes, exit out
- lea iconmap,A1 ; no, get handle to icon
- move.l A0,(A1) ; save pointer to icon data
- move.L #'ICON',-(SP) ; res type for icon
- move #128,-(SP) ; ResID of our generic icon
- _GetResource ; get generic icon from system
- move.l (SP),A4 ; save its handle in A4
- bra IconInfo ; get IconDialog box
- Quit
- _ExitToShell
- ;------------------------------------------------------------------
- IconInfo
- clr.l -(SP) ; get room for Dialog pointer
- move.w #160,-(SP) ; resource ID
- pea IconDialog(A5) ; storage for Dialog record
- move.l #-1,-(SP) ; in front of other windows
- _GetNewDialog
- lea IconHandle,A2 ; duplicate handle
- move.l (SP),(A2) ; leave handle on stack
- _DrawDialog ; draw dialog box and..
- lea IconHandle,A2
- move.l (A2),-(SP) ; set port to us
- _SetPort
- DialogLoop
- bsr Outline ; outline the 'quit' button
- bsr GetFrames ; draw our three icon frames
- clr.l -(SP) ; no filter proc
- pea ItemHit ; VAR ItemHit
- _ModalDialog
- move ItemHit,D0 ; Get Item chosen
- cmp.b #1,D0 ; quit?
- beq.s CloseIt
- cmp.b #2,D0 ; get appl. icon?
- beq.s GetFile
- bra DialogLoop ; no,wait for a valid choice
- CloseIt
- move.l (A2),-(SP) ; get dialog ptr.
- _CloseDialog ; close dialog
- _ExitToShell ; exit...
- GetFile
- move.w #100,-(sp) ; upper corner of reply box
- move.w #100,-(sp)
- pea scratch ; dummy string
- clr.l -(sp) ; filter
- move #1,-(sp) ; only applications
- pea apptype ; type list
- clr.l -(sp) ; dialog hook
- pea appreply ; reply record
- move #2,-(sp) ; standard file reply dialog
- _pack3
- move rgood+appreply,d0 ; was a file chosen?
- beq DialogLoop ; no, return
- lea parmblock(A5),A0 ; A0-> parameter block
- clr.l ioCompletion(A0) ; no completion routine
- lea appreply,A1 ; A1-> reply record
- move.w 6(A1),ioVRefNum(A0) ; get drive refnum
- clr.l ioVNPtr(A0) ; volume name pointer
- _SetVol
- SearchIcon
- clr -(SP) ; room for resource file ref num
- lea rname+appreply,A1 ; get filename
- move.l A1,-(SP)
- _OpenResFile ; open resource file
- move (SP),D7 ; D7=refnum
- cmpi #-1,D7 ; error?(no resources)
- Bne ValidName ; no,get filename
- bra NoRez ; yes,beep and return
- NoRez
- move #20,-(SP)
- _SysBeep
- bra DialogLoop
- ValidName
- CheckDItem #3 ; get statictext handle
- move.l theItem(A5),-(SP)
- pea rname+appreply ; get our filename
- _SetIText ; print it in dialog
- clr -(SP) ; room for # of icons
- move.L #'ICN#',-(SP) ; resource type
- _CountResources
- move (SP),D5 ; get # of icons in file
- subq #2,D5
- cmpi #1,D5 ; is there at least one icon?
- blt NoIcon ; no, say so
- bra DoIcon ; otherwise,prepare to plot it
- DoIcon
- move #1,D6 ; get first icon
- IconDraw iconrect1 ; plot it
- cmp D5,D6 ; is this the only icon?
- beq CloseRez ; yes,close resource file
- addq #1,D6 ; no,add one to counter
- bra DoIcon2 ; get second icon
- DoIcon2
- IconDraw iconrect2 ; plot second icon
- cmp D5,D6 ; is there a third icon?
- beq CloseRez ; no, close resource file
- addq #1,D6 ; yes, add one to counter
- bra DoIcon3 ; get third icon
- DoIcon3
- IconDraw iconrect3 ; plot third icon
- bra CloseRez ; close resource file
- NoIcon
- CheckDItem #3 ; get statictext handle
- move.l theItem(A5),-(SP)
- pea rname+appreply ; get our filename
- _SetIText ; print it in dialog
- move.l A4,A0 ; get handle of generic icon
- movea.l (A0),A0 ; A0-> sourcerect
- cmpa.l #0,A0
- beq CloseRez
- lea iconmap,A1 ; A1-> destrect
- movea.l (A1),A1
- move.l #128,D0 ; D0 = number of bytes to move
- _BlockMove
- pea iconrect1
- lea iconmap,A1
- move.l A1,-(SP)
- _PlotIcon ; plot generic icon
- bra DialogLoop ; return
- GetFrames
- ; print icon frames
- pea iconframe1
- _FrameRect
- pea iconframe2
- _FrameRect
- pea iconframe3
- _FrameRect
- rts
- OutLine
- ; outline first item in dialog, or 'quit' button
- CheckDItem #1
- move #3,-(SP)
- move #3,-(SP)
- _PenSize
- pea theRect(A5) ; VAR box
- move #-4,-(SP)
- move #-4,-(SP)
- _InsetRect
- pea theRect(A5)
- move #16,-(SP)
- move #16,-(SP)
- _FrameRoundRect
- rts
- CloseRez
- move D7,-(SP) ; D7=rsrc.file refnum
- _CloseResFile ; close resource file
- bra DialogLoop ; return
-
- ;----------------------Local storage-------------------
- EventRecord
-
- What: dc.w 0 ;what event number
- Message: dc.l 0 ;ptr. to msg
- When: dc.l 0 ;Time event was posted
- Point: dc.l 0 ;mouse coordinates
- Modify: dc.w 0 ;state of keys & button
-
- WWindow: dc.l 0 ;Find window's result
-
- IconHandle dc.l 0
- ItemHit dc.w 0 ; dialog items
- scratch
- dc.b 14
- dc.b ''
- dc.l 0
- apptype dc.b 'APPL'
- dcb.b 14,$ff
- appreply dc.w 5
- dc.b 63
- dcb.b 63,0
-
- iconmap dc.w 0,0,4,0,0,$20,$20
- iconrect1 dc.w 17,61,49,93
- iconrect2 dc.w 17,120,49,152
- iconrect3 dc.w 17,174,49,206
- iconframe1 dc.w 10,57,54,98
- iconframe2 dc.w 10,115,54,156
- iconframe3 dc.w 10,169,54,210
-
- ;----------------------Globals-----------------
- IconDialog ds.w DWindLen
- theType ds.w 1 ; VAR for GetDItem
- theItem ds.l 1 ; VAR for GetDItem
- theRect ds.w 4 ; VAR for GetDItem
- parmblock ds.w 80
-
-